#include "Ship.h"
#include "GameStates\GS_Play.h"
#include "EnemyShip.h"
void Ship::Init()
{
	GameObject::Init();
	coolDownTime = 0.0f;
}
void Ship::Update(float timeDelta)
{
	GameObject::Update(timeDelta);
	position = position + move*timeDelta*200.0;
	//move = Vector2f(0.0,0.0);
	coolDownTime += timeDelta;
	if(CanFire())
	{
		Fire();
		coolDownTime = 0;
	}
}
void Ship::Fire()
{
	GS_Play::GetInstance()->AddPlayerBullet(currentBullet->CreateBullet(position + Vector2f(0.0f, 50.0f)));
}
bool Ship::CanFire()
{
	if(currentBullet == NULL) return false;
	if(currentBullet->coolDownTime <= coolDownTime)
	{
		return true;
	}
	return false;
}
Ship* Ship::CreateFromName(const char* name)
{
	if(strcmp("rock", name) == 0)
	{
		return new EnemyRock();
	}
	return NULL;
}